import React, { FC, useState } from "react";

const StateDemo: FC = () => {
  // let count = 0;

  const [count, setCount] = useState(0);
  function add() {
    // count++;
    // set操作是异步的
    setCount(count + 1);
    // setCount((count) => count + 1);
    console.log(count);
  }

  return (
    <div>
      <button onClick={add}>add {count} </button>
    </div>
  );
};

export default StateDemo;
